package com.zy.baselib.tools

class TimeUtils {
    companion object{


        @JvmStatic
        fun formatTime(msec: Long): String {
            val ss = 1000
            val mi = ss * 60
            val hh = mi * 60
            val dd = hh *24

            val day = msec / dd
            val hour = (msec - day * dd) / hh
            val minute = (msec - day * dd - hour * hh) / mi
            val second = (msec - day * dd - hour * hh - minute * mi) / ss
//            val milliSecond: Long =
//                ms - day * dd - hour * hh - minute * mi - second * ss

            val sb = StringBuilder()
            if(day > 0) {
                sb.append("${day}天")
            }
            if(hour > 0) {
                sb.append("${hour}小时")
            }
            if(minute > 0) {
                sb.append("${minute}分")
            }
            if(second > 0) {
                sb.append("${second}秒")
            }

            return sb.toString()
        }

        private fun getMin(time: Long): String {
            if(time < 0) {
                return "0$time"
            }
            return "$time"
        }

    }
}